home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
tvmouse.exe
/
TMOUSE.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-03
|
4KB
|
238 lines
/*------------------------------------------------------------*/
/* filename - tmouse.cpp */
/* */
/* function(s) */
/* TMouse and THWMouse member functions */
/*------------------------------------------------------------*/
/*------------------------------------------------------------*/
/* */
/* Turbo Vision - Version 1.0 */
/* */
/* */
/* Copyright (c) 1991 by Borland International */
/* All Rights Reserved. */
/* */
/*------------------------------------------------------------*/
#define Uses_TEvent
#include <tv.h>
#if !defined( __DOS_H )
#include <Dos.h>
#endif // __DOS_H
#include "mouse.h"
uchar near THWMouse::buttonCount = 0;
Boolean near THWMouse::handlerInstalled = False;
THWMouse::THWMouse()
{
resume();
}
void THWMouse::resume()
{
OpenMouse ();
buttonCount = 2; // Must be fixed
#if 0
if( getvect( 0x33 ) == 0 )
return;
_AX = 0;
geninterrupt( 0x33 );
if( _AX == 0 )
return;
buttonCount = _BL;
_AX = 4;
_CX = 0;
_DX = 0;
geninterrupt( 0x33 );
#endif
}
THWMouse::~THWMouse()
{
suspend();
}
void THWMouse::suspend()
{
if( present() == False )
return;
hide();
if( handlerInstalled == True )
{
registerHandler( 0, 0 );
handlerInstalled = False;
}
buttonCount = 0;
CloseMouse ();
}
#pragma warn -asc
void THWMouse::show()
{
#if 1
asm push ax;
asm push es;
asm push ds;
asm push bx;
asm push si;
asm push di;
asm push cx;
asm push dx;
asm push bp;
ShowMouse ();
asm pop bp;
asm pop dx;
asm pop cx;
asm pop di;
asm pop si;
asm pop bx;
asm pop ds;
asm pop es;
asm pop ax;
#else
asm push ax;
asm push es;
if( present() )
{
_AX = 1;
geninterrupt( 0x33 );
}
asm pop es;
asm pop ax;
#endif
}
void THWMouse::hide()
{
#if 1
asm push ax;
asm push es;
asm push ds;
asm push bx;
asm push si;
asm push di;
asm push cx;
asm push dx;
asm push bp;
HideMouse ();
asm pop bp;
asm pop dx;
asm pop cx;
asm pop di;
asm pop si;
asm pop bx;
asm pop ds;
asm pop es;
asm pop ax;
#else
asm push ax;
asm push es;
if( buttonCount != 0 )
{
_AX = 2;
geninterrupt( 0x33 );
}
asm pop es;
asm pop ax;
#endif
}
#pragma warn .asc
void THWMouse::setRange( ushort rx, ushort ry )
{
if( buttonCount != 0 )
{
SetMouseRange (0, rx, 0, ry);
SetMouseScreenDimensions (rx+1, ry+1);
#if 0
_DX = rx;
_DX <<= 3;
_CX = 0;
_AX = 7;
geninterrupt( 0x33 );
_DX = ry;
_DX <<= 3;
_CX = 0;
_AX = 8;
geninterrupt( 0x33 );
#endif
}
}
void THWMouse::getEvent( MouseEventType& me )
{
MouseInfo mi;
ReadMouse (&mi);
me.buttons = mi.Buttons;
me.where.x = mi.X;
me.where.y = mi.Y;
me.doubleClick = False;
#if 0
_AX = 3;
geninterrupt( 0x33 );
_AL = _BL;
me.buttons = _AL;
me.where.x = _CX >> 3;
me.where.y = _DX >> 3;
me.doubleClick = False;
#endif
}
void THWMouse::registerHandler( unsigned mask, void (far *func)() )
{
if( !present() )
return;
#if defined( ProtectVersion )
_AX = 20;
#else
_AX = 12;
#endif
_CX = mask;
_DX = FP_OFF( func );
_ES = FP_SEG( func );
geninterrupt( 0x33 );
handlerInstalled = True;
}
TMouse::TMouse()
{
show();
}
TMouse::~TMouse()
{
hide();
}